﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PointAsLine
{
    /// <summary>
    /// 如果某些线段很短，则移除
    /// </summary>
    internal class RemoveLenthSmall
    {
        internal static List<Polyline> Remove(List<Polyline> simplifiedSegments, double threshold)
        {
            for (var i = simplifiedSegments.Count - 1; i >= 0; i--)
            {
                var polyline = new Polyline(simplifiedSegments[i]);
                var len = polyline.CalculateSegmentLength();
                if (len < threshold)
                {
                    simplifiedSegments.RemoveAt(i);
                    continue;
                }
                var area= polyline.ComputeArea();
                if (area < 250)
                {
                    simplifiedSegments.RemoveAt(i);
                    continue;
                }
            }
            return simplifiedSegments;
        }
    }
}
